package Server.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@DynamicInsert
@DynamicUpdate
public class Shop {
    @Id
    @GeneratedValue(generator = "NumberIdProduce")
    @GenericGenerator(name="NumberIdProduce", strategy="Server.tool.NumberIdProduce")
    private String uuid;

    /*
    *
    * 商品名称
    *
    * */
    @Column(unique = true)
    private String name;

    /*
    * 0是1否
    * */
    @Column(columnDefinition="int default 0")
    private Integer isIndex;
    /*
    *
    * 商品标签
    *
    * */
    @Column
    private String icon;

    /*
    *
    * 商品说明
    *
    * */
    @Column
    private String spack;

    /*
    *
    * 市场价
    *
    * */
    @Column
    private BigDecimal makePrice;

    /*
    *
    * 单位
    *
    * */
    @Column
    private String unit;

    /*
    *
    * 品牌
    *
    * */
    @Column
    private String brand;
    /*
    *
    * 产地
    *
    * */
    @Column
    private String place;

    /*
    *
    *类型
    *
    * */
    @Column
    private String type;

    /*
    *
    * 图片
    *
    * */
    @Lob
    @Column
    private String image;

    /*
    *
    * 详情
    *
    * */
    @Lob
    @Column
    private String note;

    @CreatedDate
    @Column
    private Date createTime;

    @LastModifiedDate
    @Column
    private Date modifiedTime;

    /*
    *
    * 商品分类
    *
    *  */
    @ManyToOne
    @JoinColumn(name = "shopClassId")
    private  ShopClass shopClass;

    /*
    *
    * 商品活动
    *
    * */
    @ManyToOne
    @JoinColumn(name = "shopActivityId")
    private  ShopActivity shopActivity;


    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum Status {
        ING("使用中"),
        NO("删除");
        Status(String display) {
            this.display = display;
        }
        private String display;

        public String getDisplay() {
            return display;
        }

        public void setDisplay(String display) {
            this.display = display;
        }
    }
    /**
     * 状态
     */
    @Enumerated(EnumType.STRING)
    @Column
    private Status status;

    @Column
    private BigDecimal viewMoney;

    public BigDecimal getViewMoney() {
        return viewMoney;
    }

    public void setViewMoney(BigDecimal viewMoney) {
        this.viewMoney = viewMoney;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getSpack() {
        return spack;
    }

    public void setSpack(String spack) {
        this.spack = spack;
    }

    public BigDecimal getMakePrice() {
        return makePrice;
    }

    public void setMakePrice(BigDecimal makePrice) {
        this.makePrice = makePrice;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getModifiedTime() {
        return modifiedTime;
    }

    public void setModifiedTime(Date modifiedTime) {
        this.modifiedTime = modifiedTime;
    }

    public ShopClass getShopClass() {
        return shopClass;
    }

    public void setShopClass(ShopClass shopClass) {
        this.shopClass = shopClass;
    }

    public ShopActivity getShopActivity() {
        return shopActivity;
    }

    public void setShopActivity(ShopActivity shopActivity) {
        this.shopActivity = shopActivity;
    }

    public Integer getIsIndex() {
        return isIndex;
    }

    public void setIsIndex(Integer isIndex) {
        this.isIndex = isIndex;
    }
}
